<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="x-rim-auto-match" content="none">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>{{ config('app.name', '考核系统') }}</title>
    <link rel="stylesheet" href="/addons/jquery-weui-build/css/weui.min.css">
    <link rel="stylesheet" href="/addons/jquery-weui-build/css/jquery-weui.css">
    <link rel="stylesheet" href="/css/admin/iconfont.css">
    <link rel="stylesheet" href="/css/system/front-iconfont.css?v={{time()}}">
    <link rel="stylesheet" href="/css/system/common.css">
    @if($skinid == 3)
        <link rel="stylesheet" href="/css/system/common.css?v={{time()}}">
        <link rel="stylesheet" href="/css/system/attendance.css?v={{time()}}">
    @elseif($skinid == 1)
        <link rel="stylesheet" href="/css/theme-blue/system/common.css?v={{time()}}">
        <link rel="stylesheet" href="/css/theme-blue/system/attendance.css?v={{time()}}">
    @elseif($skinid == 2)
        <link rel="stylesheet" href="/css/theme-pink/system/iconfont-pink.css">
        <link rel="stylesheet" href="/css/theme-pink/system/common.css">
        <link rel="stylesheet" href="/css/theme-pink/system/attendance.css?v={{time()}}">
    @endif
    <script src="/js/jquery-2.1.4.min.js"></script>
    <link rel="stylesheet" href="/addons/icheck-1.x/skins/square/green.css">
    <script src="/addons/icheck-1.x/icheck.min.js"></script>
    <script src="/js/date.js"></script>
    <script src="/kaohe/js/attendanceCalendar.js?v={{time()}}"></script>
    <script src="/addons/jquery-weui-build/js/jquery-weui.min.js"></script>
    <script src="/js/moment.js"></script>
</head>
<body ontouchstart>

<div class="mian-container">
    <div class="person-attendance">
        <div class="header-bk">
            <div class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__hd"><img src="{{ !empty($user->user_logo) ?asset($user->user_logo).'?v='.time():'/img/list-demo1.png'}}"></div>
                    <div class="weui-cell__bd qw-name">
                        {{$user->qw_name}}
                    </div>
                    <div class="weui-cell__ft">
                        <p class="inside-p"><span class="span-round"></span>年度<span class="span-num year-p">{{$year_param}}年</span></p>
                       {{-- <p class="inside-p"><span class="span-round"></span>本月出勤状况<span class="span-num">{{$count}}</span></p>--}}
                    </div>
                </div>
            </div>
        </div>
        <div class="calendar-div">
            <div class="div_changeMonth">
                <span onclick="upMonth()"><i class="icon iconfont icon-left"></i></span>
                <span id="div_calendar_title" class="div_target_label"></span>
                <span onclick="nextMonth()"><i class="icon iconfont icon-icon-up-copy-copy"></i></span>
            </div>
            <div id="calendar_div" class="div_calendar">
            </div>
            <div class="list-colorp">
                <p class="yellow-p"><span class="cir-span"></span>缺勤</p>
                <p class="blue-p"><span class="cir-span"></span>公假</p>
                <p class="yellow-p green"><span class="cir-span1"></span>出差</p>
                <p class="yellow-p other"><span class="cir-span2"></span>其他</p>
                <p class="green-p"><span class="cir-span"></span>加班</p>
            </div>
        </div>
        <div class="re-mark" style="">
        <div class="" >
            <p>备注</p>
            <p  id="from_container"></p>
        </div>
        </div>


    </div>
    @include('frontuser.caidan')
</div>

<script>
    $('.kaohe-item').click(function(){
        $('.front-show-hidden').toggle();
    });
    $('.set-btn').click(function () {
        $('.set-hidden').toggle();
    });
    var ac = new AttendanceCalendar("calendar_div", null, "div_calendar_title");
    ac.init();
    ac.setGetDataType(1);
    var model = {
        dValue: 'datetime',
        status: 'status',
        absense: 0,
        normal: 1,
        work:2,
        absense_normal:3,
        work_absense:4,
        work_normal:5,
        normal_work_absense:6
    };

    function upMonth() {
        ac.upMonth();
        $('.year-p').text(ac.getCurrentDate().getFullYear()+'年');
        ajax_next({{$id}});
        $("#from_container").empty();
    }
    function nextMonth() {
        ac.nextMonth();
        $('.year-p').text(ac.getCurrentDate().getFullYear()+'年');
        //console.log(ac.getCurrentDate().getFullYear());
        ajax_next({{$id}});
        $("#from_container").empty();

    }
    //日志上色
    function getData(ym) {
        var attendances = [];
        for (var i = 0; i < 30; i++) {
            var num = GetRandomNum(0, 2);
            attendances.push({day: i, status: num});
        }
        return attendances;
    }
    //初始化
    function setData(data) {
        attendances=[];
        for(var item in data) {
            for (var index = 0; index < data[item].length; index++) {
                attendances.push({datetime: item*1000,status:data[item][index]});
            }
        }
        ac.setAttendance(attendances);
    }


    ac.setModel(model);
    ac.setDate('{{$year_param}}');
    setData({!!$event !!});
    moment().format();
    myclickDate=moment(ac.getCurrentDate(),"MMM DD");
    //console.log(ac.getCurrentDate());
    console.log(myclickDate);
    ac.setClickFn(clickFn);
    function clickFn(clickDate) {
        myclickDate=moment(clickDate)

        ajax_refresh();
        $("#from_container").empty();
    }

    $('body').on('click','#leave-absence',function () {
        $(this).picker({
            title: "请选择天数",
            cols: [
                {
                    textAlign: 'center',
                    values: ['0.5天','1天']
                }
            ]
        });
    })

    $('body').on('click','#sick-leave',function () {
        $(this).picker({
            title: "请选择天数",
            cols: [
                {
                    textAlign: 'center',
                    values: ['0.5天','1天']
                }
            ]
        });
    })

    $('body').on('click','#overtime-work',function () {
        $(this).picker({
            title: "请选择天数",
            cols: [
                {
                    textAlign: 'center',
                    values: [ '1h', '2h',  '3h', '4h','5h','6h','7h','8h','9h','10h','11h','12h','13h','14h','15h','16h']
                }
            ]
        });
    })

    $('.radio').iCheck({
        checkboxClass: 'icheckbox_square-blue',  // 注意square和blue的对应关系
        radioClass: 'iradio_square-green',
        increaseArea: '20%' // optional
    });
    $('.icon-change').click(function(){
        $(this).parent().next().toggle();
        $(this).toggleClass('icon-cha');
    });

    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
    //请求上下月
    function ajax_next(id){
        var url='/admin/attendance/check/'+id;
        var time=moment(ac.getCurrentDate()).unix();
        $.ajax({
            type: 'post',
            cache: 'false',
            url: url,
            data:  'time=' + time,
            dataType: 'json',
            success: function (data) {
                if (data.status == 'success') {
                    $.toptip(data.msg,'success');
                    ac.setAttendance(setData(data.data));
                    console.log(data.data.length);
                } else {
                    $.toptip(data.msg,'error');
                }
            },
            error: function () {
                $.toptip('网络异常请重试','warning');
            }
        });
    }

    function ajax_refresh(){
        var url='/user/attendance/info?id={{$id}}';

        $.ajax({
            type: 'post',
            url: url,
            dataType: 'json',
            data:  'time=' + myclickDate.unix(),
            success: function (data) {
                var info='';
                console.log(data.data);
                if(data.data){
                    if(data.data.overtime  !=0){
                        info +='加班'+data.data.overtime+"小时"+"<br>"
                    }
                    if(data.data.early  != 0){
                        info +="早退"+"<br>"
                    }
                    if(data.data.late  !=0){
                        info +="迟到"+"<br>"
                    }
                    if(data.data.absenteeism  !=0){
                        info +="旷工"+"<br>"
                    }
                    if(data.data.business  != 0){
                        info +='事假'+data.data.business+"天"+"<br>"
                    }
                    if(data.data.sick !=0){
                        info +='病假'+data.data.sick+"天"+"<br>"
                    }
                    if(data.data.public ==1){
                        info +='年假'+"<br>"
                    }
                    if(data.data.public ==2){
                        info +='婚假'+"<br>"
                    }
                    if(data.data.public ==3){
                        info +='其它'+"<br>"
                    }
                    if(data.data.chuchai  !=0){
                        info +="出差"+"<br>"
                    }
                    if(data.data.qita  !=0){
                        info +="其他"+"<br>"
                    }
                }

                if(info==''){
                    info='没有事件'
                }
                $.toast(info,'text');
                $("#from_container").html(data.data.remark);

            },
            error: function () {
                $.toptip('网络异常请重试','warning');
                return false;
            }
        });
    }

    $(function(){
        $('[href^="tel:"]').removeAttr("href");
        setTimeout(function(){$('[href^="tel:"]').removeAttr("href"); }, 500);
    });
    $(function(){
        //$('#div_calendar_title').text('2019/01');
    });
</script>


<script src="/addons/jquery-weui-build/js/fastclick.js"></script>
<script src="/addons/jquery-weui-build/js/jquery-weui.min.js"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>

</body>
</html>













